<template>
  <div class="user-settings-page">
    <div class="content-container">
      <div class="form-container">
        <h2 class="form-title">用户设置</h2>
        <a-form
            :model="formState"
            @submit.prevent="onSubmit"
            class="settings-form"
        >
          <div class="form-section">
            <h3 class="section-title">修改密码</h3>
            <a-form-item>
              <a-input-password
                  v-model:value="formState.oldPassword"
                  placeholder="请输入旧密码"
                  class="form-input"
              />
            </a-form-item>
            <a-form-item>
              <a-input-password
                  v-model:value="formState.newPassword"
                  placeholder="请输入新密码"
                  class="form-input"
              />
            </a-form-item>
            <a-form-item>
              <a-input-password
                  v-model:value="formState.confirmPassword"
                  placeholder="请再次输入新密码"
                  class="form-input"
              />
            </a-form-item>
          </div>

          <div class="form-section">
            <h3 class="section-title">通知设置</h3>
            <a-form-item class="switch-item">
              <span>邮箱通知</span>
              <a-switch
                  v-model:checked="formState.emailNotification"
                  class="notification-switch"
              />
            </a-form-item>
          </div>

          <div class="form-section">
            <h3 class="section-title">隐私设置</h3>
            <a-checkbox-group
                v-model:value="formState.privacySettings"
                class="privacy-options"
            >
              <a-checkbox value="showEmail" class="checkbox-item">显示邮箱</a-checkbox>
              <a-checkbox value="showPhone" class="checkbox-item">显示手机号</a-checkbox>
              <a-checkbox value="showSchool" class="checkbox-item">显示学校信息</a-checkbox>
            </a-checkbox-group>
          </div>

          <div class="submit-container">
            <a-button
                type="primary"
                html-type="submit"
                class="submit-button"
            >
              保存设置
            </a-button>
          </div>
        </a-form>
      </div>
      <div class="info-container">
        <h3 class="info-title">设置说明</h3>
        <p class="info-text">在这里，您可以更新您的账户设置，包括密码、通知首选项和隐私选项。请确保您的新密码足够强大，并仔细考虑您想要公开分享的个人信息。</p>
        <p class="info-text">如果您有任何问题或需要帮助，请随时联系我们的支持团队。</p>
      </div>
    </div>
  </div>
</template>

<script setup>
import { reactive } from 'vue';

const formState = reactive({
  oldPassword: '',
  newPassword: '',
  confirmPassword: '',
  emailNotification: true,
  privacySettings: ['showEmail', 'showSchool'],
});

const onSubmit = () => {
  console.log('Form submitted:', formState);
  // 在这里添加表单提交逻辑
};
</script>

<style scoped>
.user-settings-page {
  display: block;
  padding: 0;
  margin: 0;
}

.content-container {
  display: flex;
  max-width: 1200px;
  min-width: 1000px;
  background-color: #ffffff;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
  margin-top: 0;
}

.form-container {
  flex: 2;
  padding: 20px;
}

.info-container {
  flex: 1;
  background-color: #e8eef3;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.form-title {
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 20px;
  color: #2c3e50;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.form-section {
  margin-bottom: 20px;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 15px;
  color: #34495e;
}

.form-input {
  width: 100%;
}

.switch-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.privacy-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checkbox-item {
  margin-left: 0 !important;
}

.submit-button {
  width: 100%;
  height: 40px;
  font-size: 16px;
  background-color: #e89a9a;
  border-color: #ffffff;
  transition: all 0.3s ease;
}

.submit-button:hover {
  background-color: #bf7e7e;
  border-color: #ffffff;
}

.info-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 20px;
  color: #2c3e50;
}

.info-text {
  font-size: 14px;
  line-height: 1.6;
  color: #34495e;
  margin-bottom: 15px;
}

@media (max-width: 768px) {
  .content-container {
    flex-direction: column;
  }

  .form-container, .info-container {
    padding: 20px;
  }

  .info-container {
    order: -1;
  }
}
</style>

